<pre class='metadata'>
Title: WebCodecs
Repository: wicg/web-codecs
Status: CG-DRAFT
ED: https://wicg.github.io/web-codecs/
Shortname: web-codecs
Level: 1
Group: wicg
Editor: Chris Cunningham, w3cid 114832, Google Inc. https://google.com/
Editor: Paul Adenot, w3cid 62410, Mozilla https://www.mozilla.org/
Abstract: WebCodecs is a flexible web API for encoding and decoding audio and video.
!Participate: <a href="https://github.com/wicg/web-codecs">Git Repository.</a>
!Participate: <a href="https://github.com/wicg/web-codecs/issues/new">File an issue.</a>
!Version History: <a href="https://github.com/wicg/web-codecs/commits">https://github.com/wicg/web-codecs/commits</a>
</pre>

<section class='non-normative'>
  <h2 id='introduction'>Introduction</h2>
  <em>This section is non-normative</em>
  <p>
    The introduction has not yet been written.
  </p>
  <p class='note'>
    NOTE: The interfaces that follow are a work in progress.
  </p>
</section>

<section>
  <h2 id='video-decoder-interface'>VideoDecoder Interface</h2>
  <pre class='idl'>
    [Exposed=(Window)]
    interface VideoDecoder {
        Promise&lt;void&gt; Initialize(VideoDecoderInitParameters params);
        Promise&lt;void&gt; Flush();
        void Close();

        readonly attribute WritableStream writable;  // of EncodedVideoFrame
        readonly attribute ReadableStream readable;  // of VideoFrame
    };
  </pre>
  <pre class='idl'>
    [Exposed=(Window)]
    dictionary VideoDecoderInitParameters {
      required DOMString codec;
      required DOMString profile;

      // These are the "coded size", not the "visible size"
      required unsigned long width;
      required unsigned long height;
    };
  </pre>
</section>

<section>
  <h2 id='video-encoder-interface'>VideoEncoder Interface</h2>
  <pre class='idl'>
    [Exposed=(Window)]
    interface VideoEncoder {
      Promise&lt;void&gt; Initialize(VideoEncoderInitParameters params);
      void Close();

      readonly attribute WritableStream writable;  // of VideoFrame
      readonly attribute ReadableStream readable;  // of EncodedVideoFrame
    };
  </pre>
  <pre class='idl'>
    enum VideoEncoderHardwareMode {
      "hardware",
      "software"
    };
  </pre>
  <pre class='idl'>
    [Exposed=(Window)]
    dictionary VideoEncoderInitParameters {
      required VideoEncoderHardwareMode hardware_mode;
      required DOMString codec;
      required DOMString profile;

      required unsigned long visible_width;
      required unsigned long visible_height;

      required unsigned long bitsPerSecond;
      required double framesPerSecond;

      required double maxFramesBetweenKeyFrames;
    };
  </pre>
</section>
